<template>
  <el-dialog :append-to-body="true" :close-on-click-modal="false" :before-close="cancel"
             :visible.sync="dialog" title="课程资源" append-to-body>
    <div class="vid-wrapper">
      <video width="100%" controls :src="videoUrl" ref="vido"></video>
    </div>
  </el-dialog>
</template>

<script>
  export default {
    props: {
      videoUrl: {
        type: String,
        required: true
      }
    },
    data() {
      return {
        dialog: false

      }
    },
    methods: {
      cancel() {
        this.dialog = false
        this.$refs.vido.pause()
      }
    }
  }
</script>

<style scoped>
  .vid-wrapper {
    margin-top: -10px;
    width: 100%;
    position: relative;
    padding-bottom: 56.25%; /*需要用padding来维持16:9比例,也就是9除以16*/
    height: 0;
  }

  .vid-wrapper video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%
  }
</style>
